package praktiukum1;

import java.awt.Checkbox;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.JCheckBox;





/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainGui.java
 *
 * Created on 17.10.2012, 10:01:27
 */
/**
 *
 * @author abg667
 */
public class MainGui extends javax.swing.JFrame {

    /** Creates new form MainGui */
    public MainGui() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        edi_maxRange = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        edi_stepRange = new javax.swing.JTextField();
        edi_iterations = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        chk_folge = new javax.swing.JCheckBox();
        chk_timeline = new javax.swing.JCheckBox();
        jButton1 = new javax.swing.JButton();
        lab_curr_state = new javax.swing.JLabel();
        MaxTeilsumme1 = new javax.swing.JCheckBox();
        MaxTeilsumme2 = new javax.swing.JCheckBox();
        MaxTeilsumme2_buch = new javax.swing.JCheckBox();
        MaxTeilsumme3 = new javax.swing.JCheckBox();
        MaxTeilsummeRekursiv = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("MaxRange");

        edi_maxRange.setText("1000");
        edi_maxRange.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edi_maxRangeActionPerformed(evt);
            }
        });

        jLabel2.setText("StepRange");

        edi_stepRange.setText("100");

        edi_iterations.setText("10");

        jLabel3.setText("Iterations");

        chk_folge.setText("Export Folgen");

        chk_timeline.setText("Export Timeline");
        chk_timeline.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chk_timelineActionPerformed(evt);
            }
        });

        jButton1.setText("Start");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        MaxTeilsumme1.setSelected(true);
        MaxTeilsumme1.setText("MaxTeilsumme1");
        MaxTeilsumme1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MaxTeilsumme1ActionPerformed(evt);
            }
        });

        MaxTeilsumme2.setSelected(true);
        MaxTeilsumme2.setText("MaxTeilsumme2");

        MaxTeilsumme2_buch.setSelected(true);
        MaxTeilsumme2_buch.setText("MaxTeilsumme2_buch");
        MaxTeilsumme2_buch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MaxTeilsumme2_buchActionPerformed(evt);
            }
        });

        MaxTeilsumme3.setSelected(true);
        MaxTeilsumme3.setText("MaxTeilsumme3");

        MaxTeilsummeRekursiv.setSelected(true);
        MaxTeilsummeRekursiv.setText("MaxTeilsummeRekursiv");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chk_folge)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(42, 42, 42)))
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(chk_timeline)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(edi_maxRange, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
                                .addComponent(edi_stepRange)
                                .addComponent(edi_iterations))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(65, 65, 65)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lab_curr_state)))
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(MaxTeilsumme2)
                    .addComponent(MaxTeilsumme2_buch)
                    .addComponent(MaxTeilsumme3)
                    .addComponent(MaxTeilsumme1)
                    .addComponent(MaxTeilsummeRekursiv)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(edi_maxRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(edi_stepRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(edi_iterations, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(chk_folge)
                            .addComponent(chk_timeline))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(lab_curr_state)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(MaxTeilsumme1)
                        .addGap(5, 5, 5)
                        .addComponent(MaxTeilsumme2)
                        .addGap(5, 5, 5)
                        .addComponent(MaxTeilsumme2_buch)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(MaxTeilsumme3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(MaxTeilsummeRekursiv)))
                .addContainerGap(38, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void edi_maxRangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edi_maxRangeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_edi_maxRangeActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
List<JCheckBox> boxlist = Arrays.asList(MaxTeilsumme1,MaxTeilsumme2,MaxTeilsumme2_buch,MaxTeilsumme3,MaxTeilsummeRekursiv);
List<AlgorithmObject> list = AlgorithmFactory.getAlgorithmsAsList();
List<AlgorithmObject> listrichtig = new ArrayList<AlgorithmObject>();
    String name = "";
    for (JCheckBox box : boxlist) {
        name = box.getName();
        box.isSelected();
        for (AlgorithmObject elem : list) {
            if(elem.getName().equals(box.getText()) && box.isSelected() ){
                listrichtig.add(elem);
            }
        }
    }
    System.out.println(listrichtig);

  
    int stepR = Integer.parseInt(edi_stepRange.getText()),
            maxR = Integer.parseInt(edi_maxRange.getText()),
            iter = Integer.parseInt(edi_iterations.getText());
                
                Runner.startTests(listrichtig,maxR ,stepR, chk_folge.isSelected(),chk_timeline.isSelected(),iter);
                Monitor.reset();
}//GEN-LAST:event_jButton1ActionPerformed

private void chk_timelineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chk_timelineActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_chk_timelineActionPerformed

private void MaxTeilsumme1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MaxTeilsumme1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_MaxTeilsumme1ActionPerformed

private void MaxTeilsumme2_buchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MaxTeilsumme2_buchActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_MaxTeilsumme2_buchActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainGui().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox MaxTeilsumme1;
    private javax.swing.JCheckBox MaxTeilsumme2;
    private javax.swing.JCheckBox MaxTeilsumme2_buch;
    private javax.swing.JCheckBox MaxTeilsumme3;
    private javax.swing.JCheckBox MaxTeilsummeRekursiv;
    private javax.swing.JCheckBox chk_folge;
    private javax.swing.JCheckBox chk_timeline;
    private javax.swing.JTextField edi_iterations;
    private javax.swing.JTextField edi_maxRange;
    private javax.swing.JTextField edi_stepRange;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel lab_curr_state;
    // End of variables declaration//GEN-END:variables
}
